package com.design.found.prototype.atguigu.deepclone;

import com.design.found.prototype.atguigu.Sheep;

/**
 * @ProjectName: design
 * @Package: com.design.found.prototype.atguigu
 * @ClassName: Client
 * @Author: shenaiguo
 * @Description:
 * @Date: 2020/8/30 0030 9:08
 */
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        DeepProtoType p = new DeepProtoType();
        p.name = "宋江";
        p.deepCloneableTarget = new DeepCloneableTarget("大牛", "小牛");
//方式 1  完成深拷贝
        DeepProtoType p2 = (DeepProtoType) p.clone();

        System.out.println("p.name=" + p.name + "p.deepCloneableTarget=" + p.deepCloneableTarget.hashCode());
        System.out.println("p2.name=" + p.name + "p2.deepCloneableTarget=" + p2.deepCloneableTarget.hashCode());
//方式 2  完成深拷贝
        DeepProtoType p3 = (DeepProtoType) p.deepClone();


        System.out.println("p.name=" + p.name + "p.deepCloneableTarget=" + p.deepCloneableTarget.hashCode());
        System.out.println("p3.name=" + p.name + "p2.deepCloneableTarget=" + p3.deepCloneableTarget.hashCode());
    }
}
